<template>
  <div class="job-consultant">
    <div class="job-consultant-head">职位专属顾问</div>
    <div class="job-consultant-content">
      <img :src="data?data.headPic:''" alt>
      <div class="content-right">
        <el-row class="consultant-name">{{data?data.consultantName:''}}</el-row>
        <el-row class="consultant-phone consultant-flex">
          <img src="../assets/img/job/phone.png" alt>
          {{data?data.consultantPhone:''}}
        </el-row>
        <el-row class="consultant-flex">
          <img src="../assets/img/job/time.png" alt style="margin:0 10px 0 0;">
          {{data?data.workTime:''}}
        </el-row>
      </div>
      <el-button :disabled="commDisableQ" class="primary-button" @click="doCommunication">在线沟通</el-button>
    </div>
  </div>
</template>

<script>
import _g from '../assets/utils/global'

export default {
  props: {
    jobId: {
      type: Number,
      default: 0
    },
    jrrId: {
      type: Number,
      default: 0
    },
    companyName: {
      type: String,
      default: ''
    },
    jobName: {
      type: String,
      default: ''
    },
    data: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  watch: {
    // jrrId: {
    //   immediate: true,
    //   handler(n) {
    //     console.log('jrrId change', n)
    //     this.jrrId = n
    //   }
    // }
  },
  data() {
    return {}
  },
  computed: {
    commDisableQ() {
      // return !(this.jrrId > 0)
      return false
    }
  },
  methods: {
    doCommunication() {
      console.log('consultant jrr id', this.jrrId)
      // if (this.jrrId > 0) {
      //
      // } else {
      //   _g.message('自荐才能沟通', 'warning')
      // }
      //现在后台放一条记录
      const params = {
        state: 3,
        platformId: this.data.consultantId,
        companyName: this.companyName,
        jobName: this.jobName,
        relationshipId: this.jrrId,
        jobId: this.jobId
      }
      _g.apiPost('/talent/clickCommnicationButton.do', params).then(res => {
        console.log('clickCommnicationButton', res)
        if (res && res.status === 0) {
          console.log('start communicate consultant success', params, res)
          this.$router.push({
            path: '/communication',
            query: {
              commId: res.data,
              companyName: this.companyName
            }
          })
        }
      })
    }
  },
  components: {}
}
</script>

<style lang="scss" scoped>
</style>
